package com.service.impl;

import com.dao.IRoleDao;
import com.domain.Permission;
import com.domain.Role;
import com.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 项目名称：ssm21
 * 类 名 称：RoleServiceImpl
 * 类 描 述：TODO
 * 创建时间：2020-01-19 20:30
 * 创 建 人：jacksonmike
 */
@Service
@Transactional
public class RoleServiceImpl implements IRoleService {
    @Autowired
    private IRoleDao roleDao;


    @Override
    public List<Role> findAll() throws Exception {
        return roleDao.findAll();
    }

    @Override
    public void save(Role role) throws Exception {
        roleDao.save(role);
    }

    @Override
    public Role findById(String roleId) throws Exception {
        return roleDao.findById(roleId);
    }

    @Override
    public List<Permission> findOtherPermissions(String roleId) throws Exception {
        return roleDao.findOtherPermissions(roleId);
    }

    @Override
    public void addPermissionToRole(String[] permissionIds, String roleId) {
        for (String s : permissionIds) {
            roleDao.addPermissionToRole(s, roleId);
        }
    }
}
